package com.lottery.im.module.result.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CheckBox;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lottery.im.R;
import com.lottery.im.api.result.entity.AllGameInfo;
import java.util.List;

public class AllGameAdapter extends BaseQuickAdapter<AllGameInfo, BaseViewHolder> {
  private OnGameClickListener mOnGameClickListener;

  public AllGameAdapter(@Nullable List<AllGameInfo> data) {
    super(R.layout.item_game_list, data);
  }

  @Override protected void convert(final BaseViewHolder helper, AllGameInfo item) {
    helper.setText(R.id.tv_game_mode, item.getGameTypeModeName());
    helper.setVisible(R.id.iv_game_mode, "".equals(item.getGameTypeMode()));
    GameGridAdapter mGameGridAdapter = new GameGridAdapter(mContext, item.getChildGameTypeList());
    helper.setAdapter(R.id.gv_game, mGameGridAdapter);
    CheckBox mCbCheckAll = helper.getView(R.id.cb_check_all);
    mCbCheckAll.setVisibility(View.GONE);
    mGameGridAdapter.setOnGameItemClickListener(
        childPosition -> mOnGameClickListener.onGameClick(helper.getLayoutPosition(),
            childPosition));
  }

  public void setOnGameClickListener(
      OnGameClickListener onGameClickListener) {
    mOnGameClickListener = onGameClickListener;
  }

  public interface OnGameClickListener {
    void onGameClick(int position, int childPosition);
  }
}
